package me.zhengjie.modules.serviceprovider.service;

import me.zhengjie.modules.serviceprovider.domain.TServiceproviderContract;
import me.zhengjie.modules.serviceprovider.service.dto.TServiceproviderContractDTO;
import me.zhengjie.modules.serviceprovider.service.dto.TServiceproviderContractQueryCriteria;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;

import java.util.Optional;

/**
* @author xuyukun
* @date 2019-07-20
*/
@CacheConfig(cacheNames = "tServiceproviderContract")
public interface TServiceproviderContractService {

    /**
    * queryAll 分页
    * @param criteria
    * @param pageable
    * @return
    */
    //@Cacheable(keyGenerator = "keyGenerator")
    Object queryAll(TServiceproviderContractQueryCriteria criteria, Pageable pageable);

    /**
    * queryAll 不分页
    * @param criteria
    * @return
    */
    //@Cacheable(keyGenerator = "keyGenerator")
    public Object queryAll(TServiceproviderContractQueryCriteria criteria);

    /**
     * findById
     * @param id
     * @return
     */
    //@Cacheable(key = "#p0")
    TServiceproviderContractDTO findById(Long id);

    /**
     * create
     * @param resources
     * @return
     */
    //@CacheEvict(allEntries = true)
    TServiceproviderContractDTO create(TServiceproviderContract resources);

    /**
     * update
     * @param resources
     */
    //@CacheEvict(allEntries = true)
    void update(TServiceproviderContract resources);

    /**
     * delete
     * @param id
     */
    //@CacheEvict(allEntries = true)
    void delete(Long id);


    /**
     * 根据服务商,生效日期获取有效合同
     * @param contractItemId
     * @param serviceproviderId
     * @param effectTime
     * @return
     */
    Optional<TServiceproviderContract> findLastEffectContract(Long contractItemId, Long serviceproviderId, String effectTime);
}